package com.lotterymanage.web.databinder;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.support.WebBindingInitializer;
import org.springframework.web.context.request.WebRequest;

/**
 * springmvc Web数据绑定, 例如日期.
 * @author zhangbin
 * @date Apr 24, 2010
 */
public class LotteryManageBindingInitializer implements WebBindingInitializer {

    /**
     * @param binder WebDataBinder
     * @param request WebRequest
     */
    @Override
    public void initBinder(final WebDataBinder binder, final WebRequest request) {
        //日期格式为 2009-12-20
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        //指定日期/时间解析是否不严格
        dateFormat.setLenient(false);
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
    }

}
